﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LotteryVote.Logic.Web;
using LotteryVote.Entity;
using LotteryVote.Logic;
using LotteryVote.Utility;
using LotteryVote.Entity.Bet;

namespace LotteryVote
{
    public partial class QuickBetVote : MemberPage
    {
        public IList<LotteryCompany> BetCompanyList { get; private set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            InitParams();
            if (!IsPostBack)
                ClientControler.WriteCompanyNumLenToClient(BetCompanyList);
        }
        private void InitParams()
        {
            BetCompanyList = TodayLotteryCompany.Instance.GetOpenCompany();
        }
        public string GetWagerName(AutoBetType betType, PlayWayEnum playWay)
        {
            return string.Format("wager_{0}_{1}", (int)betType, (int)playWay);
        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
            var betList = JSONHelper.ToObject<List<AutoBetItem>>(Request.Form["hd_betValue"]);
            BetFacade betFacade = new BetFacade();
            var returnValue = betFacade.AddBet(CurrentUser, LotterySpeciesEnum.VietnamLottery, betList);
            ShowMessage("Bet Result", returnValue);
        }
    }
}